package com.ruoyi.myplayer.mapper;

import java.util.List;
import java.util.Map;

import com.ruoyi.myplayer.domain.PlayerSong;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 歌曲Mapper接口
 * 
 * @author ruoyi
 * @date 2025-04-09
 */
public interface PlayerSongMapper 
{
    /**
     * 查询歌曲
     * 
     * @param id 歌曲主键
     * @return 歌曲
     */
    public PlayerSong selectPlayerSongById(Long id);


    /**
     * 查询歌曲列表
     * 
     * @param playerSong 歌曲
     * @return 歌曲集合
     */
    public List<PlayerSong> selectPlayerSongList(PlayerSong playerSong);

    public List<PlayerSong> selectPlayerSongPage(@Param("vo") PlayerSong playerSong);
    /**
     * 新增歌曲
     * 
     * @param playerSong 歌曲
     * @return 结果
     */
    public int insertPlayerSong(PlayerSong playerSong);

    /**
     * 修改歌曲
     * 
     * @param playerSong 歌曲
     * @return 结果
     */
    public int updatePlayerSong(PlayerSong playerSong);

    /**
     * 删除歌曲
     * 
     * @param id 歌曲主键
     * @return 结果
     */
    public int deletePlayerSongById(Long id);

    /**
     * 批量删除歌曲
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deletePlayerSongByIds(Long[] ids);

    @Select("SELECT * FROM player_song WHERE title = #{title} AND singer = #{singer}  ")
    PlayerSong selectPlayerSongByTitle(@Param("title") String title,@Param("singer") String singer);

    /**
     * @description 获取最新单曲
     * @author lvyq
     * @throws
     * @return List<Map<Object>>
     * @time 2025-04-15 17:04
     */
    List<Map<String, Object>> getNewSong();

    @Select("SELECT id,title,song,lrc,bg_img AS bgImg,singer,create_time AS createTime,re_num AS reNum,onkey ,type FROM player_song  WHERE onkey= #{key}  ")
    PlayerSong selectPlayerSongByOnKey(@Param("key") String key);


    List<Map<String, Object>> search(@Param("searchVal") String searchVal);

    @Select("SELECT COUNT(id) FROM player_album_song WHERE singer_id=#{singerId} AND album_id = #{albumId} AND song_id =#{songId}")
    Long select(@Param("singerId") Long singerId,@Param("albumId") Long albumId,@Param("songId") Long songId);

    @Insert("INSERT INTO  player_album_song (  `singer_id`, `album_id`, `song_id`, `create_data`) VALUES (  #{singerId} , #{albumId}, #{songId},NOW())")
    void band(@Param("singerId") Long singerId,@Param("albumId") Long albumId,@Param("songId") Long songId);

    @Select("SELECT * FROM player_song where singer = '' ")
    List<PlayerSong> selectnll();

    @Select("SELECT * FROM `init` WHERE del =0 ORDER BY id ASC LIMIT 1")
    Map<String, Object> selectOnInit();

    @Update("UPDATE init SET del =1 WHERE id = #{id}")
    void  updateInit(@Param("id") Integer id);

    @Select("SELECT apk_name AS apkName,version,content,patch_url AS patchUrl ,upd_version AS updVersion FROM `player_version` WHERE version  =#{versionCode}")
    Map<String, Object> upVersion(@Param("versionCode") Integer versionCode);
}
